package com.liang.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.liang.entity.CBlog;
import com.liang.mapper.CBlogMapper;
import com.liang.service.CBlogService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author 李昂
 * @since 2020-11-30
 */
@Service
public class CBlogServiceImpl extends ServiceImpl<CBlogMapper, CBlog> implements CBlogService {

    //写博客
    @Override
    public boolean WriteBlog(CBlog blog) {
        return this.save(blog);
    }

    @Override
    public List<CBlog> getBlog(String id, String type) {
        return this.baseMapper.getBlog(id, type);
    }

    @Override
    public String getContainer(int bid) {
        return this.baseMapper.getContainer(bid);
    }

    @Override
    public boolean modifyBlog(int bid, String title, String container, String type) {
        return this.baseMapper.modifyBlog(bid, title, container, type);
    }

    @Override
    @Transactional
    public boolean deleteBlog(int bid) {
        this.baseMapper.deletePraise(bid);
        return this.removeById(bid);
    }

    @Override
    public boolean lookBlog(int bid) {
        int total = this.baseMapper.lookTotal(bid);
        return this.baseMapper.lookBlog(bid, total);
    }

    @Override
    @Transactional
    public boolean Praise(int bid, String id) {
        this.baseMapper.insertPraise(bid, id);
        int total = this.baseMapper.praiseTotal(bid);
        return this.baseMapper.Praise(bid, total);
    }

    @Override
    public int getPraise(int bid, String id) {
        return this.baseMapper.getPraise(bid, id);
    }

    @Override
    public boolean commentTotal(int bid) {
        int total = this.baseMapper.commentTotal(bid);
        return this.baseMapper.comment(bid, total);
    }

    @Override
    public boolean produceBlog() {
        return this.baseMapper.produceBlog();
    }

    @Override
    public boolean deleteProduce() {
        return this.baseMapper.deleteProduce();
    }

    @Override
    public List<CBlog> getHistoryBlogData(String id) {
        return this.baseMapper.getHistoryBlogData(id);
    }

    @Override
    public List<CBlog> getBlogType(String id) {
        return this.baseMapper.getBlogType(id);
    }

    @Override
    public IPage<CBlog> selectPageBlog(Page<CBlog> page, Integer state) {
        return this.baseMapper.selectPageBlog(page, state);
    }

    @Override
    public List<CBlog> BlogSearch(String title) {
        return this.baseMapper.BlogSearch(title);
    }


}
